package com.lovo.roomProject.system.service.impl;

import com.lovo.roomProject.pojo.CutPageBean;
import com.lovo.roomProject.pojo.SystemDO;
import com.lovo.roomProject.system.dao.SystemDAO;
import com.lovo.roomProject.system.dao.impl.SystemDAOImpl;
import com.lovo.roomProject.system.service.SystemService;

import java.util.List;

public class SystemServiceImpl implements SystemService {
    private SystemDAO systemDAO=new SystemDAOImpl();
    @Override
    public List listUser() {
        return systemDAO.listUser();
    }

    @Override
    public void insert(SystemDO systemDO) {
        systemDAO.insert(systemDO);
    }

    @Override
    public void delete(int id) {
        systemDAO.delete(id);
    }

    @Override
    public SystemDO listUser(String userName) {
        return systemDAO.listUser(userName);
    }

    @Override
    public SystemDO listUser(int id) {
        return systemDAO.listUser(id);
    }

    @Override
    public CutPageBean listSystemPage(int current) {
        return systemDAO.listSystemPage(current);
    }

    @Override
    public void update(SystemDO systemDO) throws Exception{
        SystemDO lodSystem=systemDAO.listUser(systemDO.getId());
        if (lodSystem.getGrade()!=null && lodSystem.getGrade().equals(systemDO.getGrade())){
            throw new Exception("没有修改等级");
        }
        systemDAO.update(systemDO);
    }
}
